import $store from '@/store/index.js';
import groupSqlite from "@/sqlite_services/group.js"
//群信息更新或配置更新或
const handle = async(data)=>{
	try{
		console.log(data.group_info);
		let mydata = {
		    "group_id": data.group_info.group_id,
		    "g_no": data.group_info.g_no,
		    "creator_id": data.group_info.creator_id,
		    "avatar_url": data.group_info.avatar_url,
		    "group_name": data.group_info.group_name,
		    "description": data.group_info.description,
		    "notice": data.group_info.notice,
		    "create_time": data.group_info.create_time,
		    "update_time": data.group_info.update_time,
		    "is_review": data.group_info.is_review,
		    "is_invitation": data.group_info.is_invitation,
		    "is_muted": data.group_info.is_muted,
		    "default_qun": data.group_info.default_qun,
		    "is_vip": data.group_info.is_vip,
		    "qun_level": data.group_info.qun_level,
		    "show_sys_msg": data.group_info.show_sys_msg,
		    "show_online_number": data.group_info.show_online_number,
		    "show_ip": data.group_info.show_ip,
		    "show_history": data.group_info.show_history,
		    "show_qun_number": data.group_info.show_qun_number,
		    "can_delete_quit_msg": data.group_info.can_delete_quit_msg,
		    "can_withdraw_self_msg": data.group_info.can_withdraw_self_msg,
		    "can_withdraw_other_msg": data.group_info.can_withdraw_other_msg,
		    "can_send_images": data.group_info.can_send_images,
		    "can_send_video": data.group_info.can_send_video,
		    "can_send_audio": data.group_info.can_send_audio,
		    "can_send_card": data.group_info.can_send_card,
		    "can_quit_range": data.group_info.can_quit_range,
		    "can_add_friends": data.group_info.can_add_friends,
			"send_msg_auto_translate":data.group_info.send_msg_auto_translate,
			"can_edit_msg":data.group_info.can_edit_msg,
			"tags":data.group_info.tags,
			"tags_font_color":data.group_info.tags_font_color,
		    "can_send_msg": data.group_info.can_send_msg,
		    "show_member_list": data.group_info.show_member_list
		}
		console.log('-------',data.group_info.tags);
		
		$store.commit('updateChatGroupInfo',mydata)
		//更新正在聊天中的信息
		$store.commit('updateChatInfo', { uuid:mydata.group_id, data: {
			nickname: mydata.group_name,
			avatar_url: mydata.avatar_url,
		}});
		//更新会话列表
		$store.dispatch('updateSession',{
			chat_id:mydata.group_id, 
			data:{
				chat_name:mydata.group_name,
				nick_name:mydata.group_name,
				chat_face:mydata.avatar_url,
				chat_member_type:'',
				tags:mydata.tags, 
				tags_font_color:mydata.tags_font_color, 
			}
		})
		await groupSqlite.addOrEditGroupInfo(mydata)
		
	}catch(e){
		
	}
}
export default handle